package com.enfi.api.modules.db.dao;

import com.enfi.api.modules.db.entity.WarningView;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.support.JpaRepositoryImplementation;
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.List;

/**
 * 预警內容浏览表(WarningView)表数据库访问层
 *
 * @author wind
 * @since 2020-04-07 15:56:42
 */
 
@Repository
public interface WarningViewRepository extends JpaRepositoryImplementation<WarningView,Integer> {

    @Query(value = "SELECT IFNULL(t2.user_code,'') as userCode,IFNULL(t2.user_name,'') as userName, IFNULL(t4.post_code,'') as postCode, IFNULL(t4.post_name,'') as postName " +
            "FROM js_sys_employee t1 LEFT JOIN js_sys_user t2 " +
            "ON t1.emp_code = t2.ref_code AND t2.ref_code " +
            "IS NOT NULL LEFT JOIN js_sys_employee_post t3" +
            " ON t1.emp_code = t3.emp_code LEFT JOIN js_sys_post t4" +
            " ON t3.post_code = t4.post_code " +
            "WHERE t2.user_code in(:userCodeList)" ,nativeQuery = true)
    List findByUserCodeIn(Collection userCodeList);
}